package com.imooc.beanannotation.javabased;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.Scope;


@Configuration
@ImportResource("classpath:config.xml")
public class StoreConfig {

    @Value("${jdbc.url}")
    private String url;
    
    @Value("${jdbc.username}")
    private String username;
    
    @Value("${jdbc.password}")
    private String password;
    
    
    @Bean
    public MyDriverManager myDriverManager() {
        return new MyDriverManager(url, username, password);
    }
    
    @SuppressWarnings("rawtypes")
    @Bean(name="stringStore", initMethod="init", destroyMethod="destroy")
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public Store stringStore() {
        return new StringStore();
    }

    
    public IntegerStore integerStore() {
        return new IntegerStore();
    } 
}
